<?php
#                                                                                 
# author: Cody Sorgenfrey                                       
# (c)2013 South Hill Calvary Chapel                                               
# 
include_once("registrationManagerFunctions.php"); 
printf("<script type='text/javascript'>document.cookie = \"vars=%s_%s_%s\";</script>", $costPerPerson, $costPerCouple, $maxCost);
printf('<input type="hidden" id="itemName" name="item_name" value="%s Registration">', $title);
printf('<input type="hidden" id="itemNumber" name="item_number" value="shcc-%s">', $id);
printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/registrationManager.js'></script>");                                
?>
<style type="text/css">
	input[type="text"]
	{
		width:48%;
		max-width: 200px;
	}
	textarea
	{
		margin-top: -15px;
	}
</style>
<script type="text/javascript">
	function vbsAddMore()
	{
		var node = document.createElement("INPUT");
		node.type = "text";
		node.name = registration.formNumber+"-firstNames";
		node.placeholder = "Kids First Name";
		var newNode = registration.extraFields.appendChild(node);
		var node2 = document.createElement("INPUT");
		node2.type = "text";
		node2.name = registration.formNumber+"-lastNames";
		node2.placeholder = "Kids Last Name";
		registration.extraFields.appendChild(node2);
		var node3 = document.createElement("INPUT");
		node3.type = "text";
		node3.name = "shirtSize";
		node3.placeholder = "Shirt Size";
		registration.extraFields.appendChild(node3);
		var node4 = document.createElement("INPUT");
		node4.type = "text";
		node4.name = "age";
		node4.placeholder = "Age";
		registration.extraFields.appendChild(node4);
		var node5 = document.createElement("INPUT");
		node5.type = "text";
		node5.name = "grade";
		node5.placeholder = "Grade";
		registration.extraFields.appendChild(node5);
		var node6 = document.createElement("INPUT");
		node6.type = "text";
		node6.name = "alergies";
		node6.placeholder = "Alergies";
		registration.extraFields.appendChild(node6);
		newNode.addEventListener("keyup", countPeople, false);
	}
	function vbsPrepSubmit(id)
	{
		if (!vbsValidate()){
			return 0
		}
		for (var x=0;x<registration.numberRegistered;x++){
			registration.people[x] = document.getElementsByName(registration.formNumber+"-firstNames")[x].value;
			registration.people[x] += " " + document.getElementsByName(registration.formNumber+"-lastNames")[x].value;
		}
		if ((document.getElementById(registration.formNumber+"-notes").value != "Comments...") && (document.getElementById(registration.formNumber+"-notes").value !="")){
			registration.notes = "Notes...\r" + document.getElementById(registration.formNumber+"-notes").value + "\r\r";
		} 
		registration.notes += "Gaurdian: " + document.getElementById("0-gaurdianFirst").value + " " + document.getElementById("0-gaurdianLast").value  + "\r\r";
		for (var x=0;x<registration.numberRegistered;x++){
			registration.notes += document.getElementsByName(registration.formNumber+"-firstNames")[x].value + ":\rSize: " + document.getElementsByName("shirtSize")[x].value + "\rAge: " + document.getElementsByName("age")[x].value + "\rGrade: " + document.getElementsByName("grade")[x].value + "\rAlergies: " + document.getElementsByName("alergies")[x].value + "\r\r";
		}
		registration.newRegistration = 1;
		registration.checkOut = 0;
		if (registration.scholarship){
			if (registration.paymentType == null){
				registration.paymentType = "No payment made.";
				registration.scholarshipAmount = registration.amountDue;
				registration.amountDue = 0;
				registration.checkOut = 0;
				registration.paidInFull = 1;
			} else {
				registration.checkOut = 1;
			}
		}
		if (registration.free){
			registration.paymentType = "NA"
		}
		customSubmit(id);
	}
	function vbsValidate()
	{
		var x = "";
		if (document.getElementById("0-gaurdianFirst").value == ""){
			x += "Must have a gaurdian name to register\n";
		}
		if (registration.originalFirstName.value == ""){
			x += "Must have child's name to register\n";
		}
		if (document.getElementById("0-age").value == ""){
			x += "Must have child's age to register\n";
		}
		if (document.getElementById("0-shirtSize").value == ""){
			x += "Must have child's shirt size to register\n";
		}
		if (document.getElementById("0-grade").value == ""){
			x += "Must have child's grade to register\n";
		}
		if (document.getElementById("0-alergies").value == ""){
			x += "Must have child's alergies to register\n";
		}
		validateEmail(document.getElementById(registration.formNumber+"-email"));
		if (registration.email == ""){
			x += "Must have an email to register\n";
		}
		if (registration.phone.length != 12){
			x += "Must have a valid phone number to register\n";
		}
		if ((registration.paymentType == null) && (!registration.scholarship)){
			if (!registration.free){
				x += "Must select a payment type to register\n";
			}
		}
		if (x){
			alert(x);
			return 0;
		} else {
			return 1; 	
		}
	}

</script>
<form>
<input type='text' id='0-gaurdianFirst' name='0-gaurdian' placeholder='Gaurdians First'><br>
<input type='text' id='0-gaurdianLast' name='0-gaurdian' placeholder='Gaurdians Last'><br><br>
<input type='text' id='0-email' style='width:200px' onkeyup='validateEmail(this)' placeholder='Email'>
<span style='color:red;' id='0-email'></span><br><br>
Phone: <input type='text' maxlength='3' style='width:30px;' id='0-area' onkeyup='autoTab(this)'>
- <input type='text' maxlength='3' style='width:30px;' id='0-pre' onkeyup='autoTab(this)'>
- <input type='text' maxlength='4' style='width:40px;' id='0-post' onkeyup='registerPhone(this)'><br><br>
<input type='text' id='0-firstNames' name='0-firstNames' placeholder='Kids First Name' onkeyup='countPeople();'><br>
<input type='text' id='0-lastNames' name='0-lastNames' placeholder='Kids Last Name'><br>
<input type='text' id='0-shirtSize' name='shirtSize' placeholder='Shirt Size'><br>
<input type='text' id='0-age' name='age' placeholder='Age'><br>
<input type='text' id='0-grade' name='grade' placeholder='Grade'><br>
<input type='text' id='0-alergies' name='alergies' placeholder='Alergies'><br>
<span style='font-size:12pt; cursor:pointer;' onclick='vbsAddMore();'>+ add more kids</span>
<div id='0-people' style='max-width:300px;'></div><br>
Amount Due: $<br>
<input type='text' id ='0-amountDue' name='amountDue' value='0.00' disabled='true'><br><br>
<input type='hidden' name='0-paymentType' value='Paypal'>
<input type='hidden' id='0-scholarship'>
<textarea id='0-notes' >Comments...</textarea><br><br>
</form>                    
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
<?
printf('<input type="submit" border="0" value="Register" alt="PayPal - The safer, easier way to pay online!" onclick="vbsPrepSubmit(\'%s\')">', $id);
?>